
count = 0
sum = 0

catalog = open(r"D:\Users\sky\PycharmProjects\untitled2\dict.py")

t = len(open(r"D:\Users\sky\PycharmProjects\untitled2\dict.py").readlines())

for line in catalog.readlines():
    line = line.strip()     #去掉每行头尾空白
    print(line)
    if line == "":
        count += 1
    if line.startswith("#"):    #startswith() 方法用于检查字符串是否是以指定子字符串开头，如果是则返回 True，否则返回 False
        sum += 1

print("统计的文件行数为：%d行" %t)
print("统计文件的空行数为：%s" %count)
print("统计的注释行数为：%s" %sum)
